package com.senlingspace.system.service.impl;

import java.util.List;
import com.senlingspace.common.utils.DateUtils;
import com.senlingspace.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.senlingspace.system.mapper.SlkjWechatSmallMapper;
import com.senlingspace.system.domain.SlkjWechatSmall;
import com.senlingspace.system.service.ISlkjWechatSmallService;

/**
 * 小程序品牌故事图片Service业务层处理
 *
 * @author wangliang
 * @date 2024-12-03
 */
@Service
public class SlkjWechatSmallServiceImpl implements ISlkjWechatSmallService
{
    @Autowired
    private SlkjWechatSmallMapper slkjWechatSmallMapper;

    /**
     * 查询小程序品牌故事图片
     *
     * @param id 小程序品牌故事图片主键
     * @return 小程序品牌故事图片
     */
    @Override
    public SlkjWechatSmall selectSlkjWechatSmallById(Long id)
    {
        return slkjWechatSmallMapper.selectSlkjWechatSmallById(id);
    }

    /**
     * 查询小程序品牌故事图片列表
     *
     * @param slkjWechatSmall 小程序品牌故事图片
     * @return 小程序品牌故事图片
     */
    @Override
    public List<SlkjWechatSmall> selectSlkjWechatSmallList(SlkjWechatSmall slkjWechatSmall)
    {
        return slkjWechatSmallMapper.selectSlkjWechatSmallList(slkjWechatSmall);
    }

    /**
     * 新增小程序品牌故事图片
     *
     * @param slkjWechatSmall 小程序品牌故事图片
     * @return 结果
     */
    @Override
    public int insertSlkjWechatSmall(SlkjWechatSmall slkjWechatSmall)
    {
        SlkjWechatSmall wechatSmall = new SlkjWechatSmall();
        wechatSmall.getModulesType();
        List<SlkjWechatSmall> slkjWechatSmalls = slkjWechatSmallMapper.selectSlkjWechatSmallList(wechatSmall);
        if(slkjWechatSmalls.size() > 0 ){
            throw new IllegalArgumentException("该模块下已有数据，请去修改");
        }
        slkjWechatSmall.setCreateTime(DateUtils.getNowDate());
        slkjWechatSmall.setCreateBy(SecurityUtils.getUsername());
        return slkjWechatSmallMapper.insertSlkjWechatSmall(slkjWechatSmall);
    }

    /**
     * 修改小程序品牌故事图片
     *
     * @param slkjWechatSmall 小程序品牌故事图片
     * @return 结果
     */
    @Override
    public int updateSlkjWechatSmall(SlkjWechatSmall slkjWechatSmall)
    {
        SlkjWechatSmall small = new SlkjWechatSmall();
        small.setModules(slkjWechatSmall.getModules());
        small.setModulesType(slkjWechatSmall.getModulesType());
        List<SlkjWechatSmall> slkjWechatSmalls = slkjWechatSmallMapper.selectSlkjWechatSmallList(small);
        if(slkjWechatSmalls.size() > 0 ){
            throw new IllegalArgumentException("该模块下已有数据,请检查数据是否正确");
        }
        slkjWechatSmall.setUpdateTime(DateUtils.getNowDate());
        slkjWechatSmall.setUpdateBy(SecurityUtils.getUsername());
        return slkjWechatSmallMapper.updateSlkjWechatSmall(slkjWechatSmall);
    }

    /**
     * 批量删除小程序品牌故事图片
     *
     * @param ids 需要删除的小程序品牌故事图片主键
     * @return 结果
     */
    @Override
    public int deleteSlkjWechatSmallByIds(Long[] ids)
    {
        return slkjWechatSmallMapper.deleteSlkjWechatSmallByIds(ids);
    }

    /**
     * 删除小程序品牌故事图片信息
     *
     * @param id 小程序品牌故事图片主键
     * @return 结果
     */
    @Override
    public int deleteSlkjWechatSmallById(Long id)
    {
        return slkjWechatSmallMapper.deleteSlkjWechatSmallById(id);
    }
}
